import java.awt.Color;
import java.awt.event.*;

import javax.swing.*;


public class MultiplayerComponentUI {
	// phase one - from start up to pressing done the first time
	private JTextField playerNameTextField;
	private JComboBox tokenComboBox;
	private JButton diceButton;
	
	//phase two - from end of phase one up to the end of rolling
	private JLabel playerNameLabel;
	private JLabel tokenLabel;
	
	private JLabel highRollLabel;
	
	private HighRollDiceUI highRollDice;
	
	private int highRoll;
	private String playerName;
	private String token; //this is a variable for the component
	private boolean active;
	

	public MultiplayerComponentUI(){
		
		String choices[] = {
		
				"Lalake - Itim",
				"Lalake - Bughaw",
				"Lalake - Ube",
				"Lalake - Pula",
				"Lalake - Luntian",
				"Lalake - Kahel",
				"Lalake - Ulap Bughaw",
				"Lalake - Dilaw",
				"Babae - Itim",
				"Babae - Bughaw",
				"Babae - Ube",
				"Babae - Pula",
				"Babae - Luntian",
				"Babae - Kahel",
				"Babae - Ulap Bughaw",
				"Babae - Dilaw",
				
		};
		ImageIcon pic = new ImageIcon("Graphics/HighRoll.png");
		this.playerNameTextField = new JTextField();
		this.tokenComboBox = new JComboBox(choices);
		this.diceButton = new JButton(pic);
		this.diceButton.setBackground(new Color(0, 0, 0, 0));
		this.diceButton.setForeground(new Color(0, 0, 0, 0));
		this.diceButton.setRolloverEnabled(false);
		this.diceButton.setBorderPainted(false);
		this.highRollLabel = new JLabel("High Roll: ");
		
		this.playerNameLabel = new JLabel();
		this.tokenLabel = new JLabel();
		
		
		this.diceButton.addActionListener(new ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                diceButtonActionListener(evt);
            }
        });
		
	}
	
	private void diceButtonActionListener(ActionEvent evt) {
		
		this.diceButton.setVisible(false);
		this.highRollDice = new HighRollDiceUI(this);
		this.highRollDice.setVisible(true);

    }
	
	public void setVisibilityOfPhaseOneComponents(Boolean visibility){
		
		this.playerNameTextField.setVisible(visibility);
		this.tokenComboBox.setVisible(visibility);
		this.diceButton.setVisible(visibility);
		
	}
	
	public void setVisibilityOfPhaseTwoComponents(Boolean visibility){
		
		this.playerNameLabel.setVisible(visibility);
		this.tokenLabel.setVisible(visibility);
		
	}
	
	public void getInput(){
		
		this.playerName = this.playerNameTextField.getText();
		this.token = this.tokenComboBox.getSelectedItem().toString();
		
	}
	
	public void setPhaseTwoComponents(){
		
		this.playerNameLabel.setText(this.playerName);
		this.tokenLabel.setText(this.token);
		
	}
	
	//getters and setters
	
	public JTextField getPlayerNameTextField() {
		return playerNameTextField;
	}

	public JComboBox getTokenComboBox() {
		return tokenComboBox;
	}

	public JLabel getHighRollLabel() {
		return highRollLabel;
	}

	public JButton getDiceButton() {
		return diceButton;
	}

	public JLabel getPlayerNameLabel() {
		return playerNameLabel;
	}

	public JLabel getTokenLabel() {
		return tokenLabel;
	}

	public HighRollDiceUI getHighRollDice() {
		return highRollDice;
	}

	public int getHighRoll() {
		return highRoll;
	}

	public String getPlayerName() {
		return playerName;
	}

	public String getToken() {
		return token;
	}

	public boolean isActive() {
		return active;
	}

	public void setPlayerNameTextField(JTextField playerNameTextField) {
		this.playerNameTextField = playerNameTextField;
	}

	public void setTokenComboBox(JComboBox tokenComboBox) {
		this.tokenComboBox = tokenComboBox;
	}

	public void setHighRollLabel(JLabel highRollLabel) {
		this.highRollLabel = highRollLabel;
	}

	public void setDiceButton(JButton diceButton) {
		this.diceButton = diceButton;
	}

	public void setPlayerNameLabel(JLabel playerNameLabel) {
		this.playerNameLabel = playerNameLabel;
	}

	public void setTokenLabel(JLabel tokenLabel) {
		this.tokenLabel = tokenLabel;
	}

	public void setHighRollDice(HighRollDiceUI highRollDice) {
		this.highRollDice = highRollDice;
	}

	public void setHighRoll(int highRoll) {
		this.highRoll = highRoll;
	}

	public void setPlayerName(String playerName) {
		this.playerName = playerName;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public void setActive(boolean active) {
		this.active = active;
	}
	
	
	
	
	
	
	
}
